$(function(){
	$(".managerSelector").each(function(){
		var orgId = $("#orgId").val();
		var url="system/organization!selectManager.action?organization.id="+orgId;
		$.ajax({
			url: url,
			dataType:'json',
			success:function(data) {
				for(var i=0;i<data.length;i++){
					$("#sel").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
				}
				$("#sel").bind("change",function(){
					var checkText = $("#sel").find("option:selected").val();
					$("#manager").val(checkText);
				});
			}
		});
	});
	$('form').mothinForm();
	$("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
		filter: function() {
			return $(this).is(":visible");
		},
		submitSuccess: function($form, event) {
			$.ajax({
        		type: 'POST',
                url: $form.attr('action'),
                data: $form.serialize(),
                success: function(data){
                	if(data.ok){
                		showMessage('负责人设置成功',function(){
                			closeDialog();
                		});
        	    	}else{
        	    		showMessage('负责人设置失败',null,'error');
        	    	}
  				}
   			});
     		event.preventDefault();
        }
	});
});